package com.example.demo.day0228;

public class DemoEnum  {
    public static void main(String[] args) {
        Season spring = Season.SPRING;//Season.SPRING获取一个Season的对象
        spring.showInfo();

        Season spring1 = Season.SPRING;
        System.out.println(spring.equals(spring1));//每次执行Season.SPRING获得的都是相同的对象，枚举类中的每个枚举都是单例模式

        Season summer = Season.SUMMER;
        summer.showInfo();

        Season autumn = Season.AUTUMN;
        autumn.showInfo();

        Season winter = Season.WINTER;
        winter.showInfo();
        winter.test();

        System.out.println(spring+"ordinal:"+spring.ordinal());//得到当前枚举常量的次序，次序从0开始
        System.out.println(spring.compareTo(spring1));//比较两个枚举常量的大小
        System.out.println(spring == spring1);//比较两个枚举常量是否相等
        System.out.println(spring.getDeclaringClass());//得到枚举常量所属的枚举类
        System.out.println(spring.name());//得到当前枚举常量的名称
        System.out.println(spring.toString());//得到当前枚举常量的名称，优先使用toString

    }
}

